GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 137f54...278f6d )
by Florian
01:11
created

Marker.store   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 8
rs 9.4285
1
/*jslint
2
  indent: 4
3
*/
4
5
/*global
6
  $, google,
7
  Coordinates, IconFactory, Lines, Storage,
8
  id2alpha
9
*/
10
11
function Marker(parent, id) {
12
    'use strict';
13
14
    this.m_parent = parent;
15
    this.m_id = id;
16
    this.m_alpha = id2alpha(id);
17
    this.m_free = true;
18
    this.m_name = "";
19
    this.m_color = "FF0000";
20
    this.m_iconColor = "";
21
    this.m_iconLabel = "";
22
    this.m_miniIconUrl = "";
23
    this.m_marker = null;
24
    this.m_circle = null;
25
}
26
27
28
Marker.prototype.toString = function () {
29
    'use strict';
30
31
    return this.getAlpha() + ":" +
32
            this.getPosition().lat().toFixed(6) + ":" +
33
            this.getPosition().lng().toFixed(6) + ":" +
34
            this.getRadius() + ":" +
35
            this.getName() + ":" +
36
            this.m_color;
37
};
38
39
40
Marker.prototype.toXmlWpt = function () {
41
    'use strict';
42
43
    var data = '';
44
    data += '<wpt lat="' + this.getPosition().lat().toFixed(8) + '" lon="' + this.getPosition().lng().toFixed(8) + '">\n';
45
    data += '    <name>' + this.getName() + '</name>\n';
46
    data += '    <sym>flag</sym>\n';
47
    if (this.getRadius() > 0) {
48
        data += '    <extensions>\n';
49
        data += '      <wptx1:WaypointExtension>\n';
50
        data += '        <wptx1:Proximity>' + this.getRadius() + '</wptx1:Proximity>\n';
51
        data += '      </wptx1:WaypointExtension>\n';
52
        data += '    </extensions>\n';
53
    }
54
    data += '</wpt>';
55
56
    return data;
57
};
58
59
60
Marker.prototype.isFree = function () {
61
    'use strict';
62
63
    return this.m_free;
64
};
65
66
67
Marker.prototype.clear = function () {
68
    'use strict';
69
70
    if (this.m_free) {
71
        return;
72
    }
73
74
    this.m_free = true;
75
    this.m_marker.setMap(null);
76
    this.m_marker = null;
77
    this.m_circle.setMap(null);
78
    this.m_circle = null;
79
    this.m_color = "FF0000";
80
    this.m_iconColor = "";
81
    this.m_iconLabel = "";
82
83
    $('#dyn' + this.m_id).remove();
84
85
    Lines.updateLinesMarkerRemoved(this.m_id);
86
    this.m_parent.handleMarkerCleared();
87
};
88
89
90
Marker.prototype.getId = function () {
91
    'use strict';
92
93
    return this.m_id;
94
};
95
96
97
Marker.prototype.getAlpha = function () {
98
    'use strict';
99
100
    return this.m_alpha;
101
};
102
103
104
Marker.prototype.getName = function () {
105
    'use strict';
106
107
    return this.m_name;
108
};
109
110
111
Marker.prototype.setName = function (name) {
112
    'use strict';
113
114
    this.m_name = name;
115
    this.update();
116
};
117
118
119
Marker.prototype.setPosition = function (position) {
120
    'use strict';
121
122
    this.m_marker.setPosition(position);
123
    this.m_circle.setCenter(position);
124
    this.update();
125
};
126
127
128
Marker.prototype.getPosition = function () {
129
    'use strict';
130
131
    return this.m_marker.getPosition();
132
};
133
134
135
Marker.prototype.setRadius = function (radius) {
136
    'use strict';
137
138
    this.m_circle.setRadius(radius);
139
    this.update();
140
};
141
142
143
Marker.prototype.getRadius = function () {
144
    'use strict';
145
146
    return this.m_circle.getRadius();
147
};
148
149
150
Marker.prototype.setNamePositionRadiusColor = function (name, position, radius, color) {
151
    'use strict';
152
153
    this.m_name = name;
154
    this.m_marker.setPosition(position);
155
    this.m_circle.setCenter(position);
156
    this.m_circle.setRadius(radius);
157
    this.m_color = color;
158
    this.update();
159
};
160
161
162
Marker.prototype.initialize = function (map, name, position, radius, color) {
163
    'use strict';
164
165
    this.m_free = false;
166
    this.m_name = name;
167
    this.m_color = color;
168
    if (!((/^([a-fA-F0-9]{6})$/).test(this.m_color))) {
169
        var colors = ["FF0000", "00FF00", "0000FF", "FFFF00", "FF00FF", "00FFFF", "FFFFFF"];
170
        this.m_color = colors[this.m_id % 7];
171
    }
172
    this.m_iconLabel = name;
173
    this.m_iconColor = this.m_color;
174
175
    var self = this;
176
177
    this.m_miniIcon = IconFactory.createMiniIcon(this.m_alpha, this.m_color);
178
179
    this.m_marker = new google.maps.Marker({
180
        position: position,
181
        map: map,
182
        icon: IconFactory.createMapIcon(this.m_name, this.m_color),
183
        optimized: false,
184
        draggable: true
185
    });
186
187
    google.maps.event.addListener(this.m_marker, "drag", function () {
188
        self.update();
189
    });
190
    google.maps.event.addListener(this.m_marker, "dragend", function () {
191
        self.update();
192
    });
193
194
    this.m_circle = new google.maps.Circle({
195
        center: position,
196
        map: map,
197
        strokeColor: "#" + this.m_color,
198
        strokeOpacity: 1,
199
        fillColor: "#" + this.m_color,
200
        fillOpacity: 0.25,
201
        strokeWeight: 1,
202
        radius: radius
203
    });
204
};
205
206
207
Marker.prototype.update = function () {
208
    'use strict';
209
210
    if (this.m_free) {
211
        return;
212
    }
213
214
    var pos = this.m_marker.getPosition(),
215
        radius = this.m_circle.getRadius();
216
217
    this.m_circle.setCenter(pos);
218
219
    this.store();
220
221
    $('#dyn' + this.m_id + ' > .view .name').html(this.m_name);
222
    $('#dyn' + this.m_id + ' > .view .coords').html(Coordinates.toString(pos));
223
    $('#dyn' + this.m_id + ' > .view .radius').html(radius);
224
    $('#dyn' + this.m_id + ' > .edit .name').val(this.m_name);
225
    $('#dyn' + this.m_id + ' > .edit .coords').val(Coordinates.toString(pos));
226
    $('#dyn' + this.m_id + ' > .edit .radius').val(radius);
227
    $('#dyn' + this.m_id + ' > .edit .color').val('#' + this.m_color);
228
229
    if ((this.m_iconLabel !== this.m_name) || (this.m_iconColor !== this.m_color)) {
230
        this.m_iconLabel = this.m_name;
231
        this.m_iconColor = this.m_color;
232
        this.m_marker.setIcon(IconFactory.createMapIcon(this.m_name, this.m_color));
233
        this.m_miniIcon = IconFactory.createMiniIcon(this.m_alpha, this.m_color);
234
        this.m_circle.setOptions({strokeColor: "#" + this.m_color, fillColor: "#" + this.m_color});
235
    }
236
    $('#dyn' + this.m_id + ' > .view .icon').attr("src", this.m_miniIcon.url);
237
    $('#dyn' + this.m_id + ' > .view .icon').attr("style", "width: " + this.m_miniIcon.width + "px; height: " + this.m_miniIcon.height + "px;");
238
239
    Lines.updateLinesMarkerMoved(this.m_id);
240
};
241
242
243
Marker.prototype.store = function () {
244
    'use strict';
245
246
    var pos = this.m_marker.getPosition(),
247
        radius = this.m_circle.getRadius();
248
249
    Storage.set('marker' + this.m_id, pos.lat().toFixed(6) + ":" + pos.lng().toFixed(6) + ":" + radius + ":" + this.m_name + ":" + this.m_color);
250
};
251